package com.makeblock.demo.testdatabinding.list;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.makeblock.demo.testdatabinding.R;
import com.makeblock.demo.testdatabinding.model.DataModel;

import java.util.ArrayList;
import java.util.List;

public class RecyclerViewActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_recycler_view);
        RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
        List<DataModel> list = new ArrayList<>();
        for (int i = 0; i < 100; ++i) {
            list.add(new DataModel(i + "", i % 2 == 0, (i + 1) + ""));
        }
        recyclerView.setAdapter(new RecyclerViewAdapter(list));
        recyclerView.setLayoutManager(new LinearLayoutManager(this));
    }
}
